﻿
@{
    Layout = null;
}
<div>
    <table class="form">
        <tr>
            <td class="formValue"><span style="float:left;width:40%;padding-top:5px;">结算类型：</span>
                                  <div style="width:55%;float:right;">
                                      <select class="form-control" id="sel_jsxz">
                                          <option value="">不限</option>
                                          <option value="1">出院结算</option>
                                          <option value="2">中途结算</option>
                                      </select>
                                  </div>
            </td>
            <td class="formValue"><input type="button" id="btn_settsubmit" class="btn btn-primary" value=" 查 询 " />
            </td>
            <th class="formTitle"></th>
            <td class="formValue"></td>
            <th class="formTitle"></th>
            <td class="formValue"></td>
        </tr>
    </table>
    <table id="gridListsett"></table>
</div>
<div style="border:1px solid #ff6a00;border-radius:5px;">
    <table class="form" style="margin:5px 5px;">
        <tr style="border-bottom:1px solid #ddd0d0;border-bottom-left-radius:5px;border-bottom-right-radius:5px;color:#ff0000;font-weight:bold;">
            <th class="formTitle">结算时间：</th>
            <td class="formValue" colspan="2"><label id="lb_setl_time"></label></td>
            <th class="formTitle"></th>
            <td class="formValue"></td>
            <th class="formTitle"></th>
            <td class="formValue"></td>
        </tr>
        <tr>
            <th class="formTitle">费用总额：</th>
            <td class="formValue">￥<label id="lb_medfee_sumamt">0.00</label></td>
            <th class="formTitle">现金支付合计：</th>
            <td class="formValue">￥<label id="lb_xjzf">0.00</label></td>
            <th class="formTitle">现金支付方式：</th>
            <td class="formValue"><label id="lb_xjzffsmc"></label></td>
        </tr>
        <tr>
            <th class="formTitle">账户支付：</th>
            <td class="formValue">￥<label id="lb_acct_pay">0.00</label></td>
            <th class="formTitle">非医保现金计费：</th>
            <td class="formValue">￥<label id="lb_fybxjzf">0.00</label></td>
        </tr>
        <tr>
            <th class="formTitle">医保现金计费：</th>
            <td class="formValue">￥<label id="lb_psn_cash_pay">0.00</label></td>
            <th class="formTitle">统筹支付：</th>
            <td class="formValue">￥<label id="lb_hifp_pay">0.00</label></td>
            <th class="formTitle">公务员补助：</th>
            <td class="formValue">￥<label id="lb_cvlserv_pay">0.00</label></td>
        </tr>
        <tr>
            <th class="formTitle">单病种医疗垫支：</th>
            <td class="formValue">￥<label id="lb_hosp_part_amt">0.00</label></td>

            <th class="formTitle">大额理赔支付：</th>
            <td class="formValue">￥<label id="lb_hifob_pay">0.00</label></td>
        </tr>
        <tr>
            <th class="formTitle">企业医疗保险支出：</th>
            <td class="formValue">￥<label id="lb_hifes_pay">0.00</label></td>
            <th class="formTitle">居民大病支出：</th>
            <td class="formValue">￥<label id="lb_hifmi_pay">0.00</label></td>
            <th class="formTitle">医疗救助基金支出：</th>
            <td class="formValue">￥<label id="lb_maf_pay">0.00</label></td>
        </tr>
        <tr>
            <th class="formTitle">账户共济支付：</th>
            <td class="formValue">￥<label id="lb_acct_mulaid_pay">0.00</label></td>
            <th class="formTitle">其他：</th>
            <td class="formValue">￥<label id="lb_oth_pay">0.00</label></td>
            <th class="formTitle">符合政策范围金额：</th>
            <td class="formValue">￥<label id="lb_inscp_scp_amt">0.00</label></td>
        </tr>
        <tr>
            <th class="formTitle">实际支付起付线：</th>
            <td class="formValue">￥<label id="lb_act_pay_dedc">0.00</label></td>
        </tr>
    </table>
</div>
<script>
    $(function () {
        $("#btn_settsubmit").click(function () {
            //刷新结算信息
            $("#gridListsett").jqGrid('setGridParam', {
                postData: { zyh: $("#zyh").text(), jsxz: $("#sel_jsxz option:selected").val() }
            }).trigger('reloadGrid');
            $("#dv_sett label").each(function () {
                $(this).html("");
            });
        });
    });
    function gridListSett(zyh) {
        var $gridList = $("#gridListsett");
        $gridList.dataGrid({
            url: "/PatientManage/PatientCenter/PatZySettInfo",
            postData: { zyh: zyh },
            height: 200,
            colModel: [
                { label: '主键', name: 'jsnm', hidden: true },
                { label: 'setl_id', name: 'setl_id', hidden: true },
                {
                    label: '结算日期', name: 'setl_time', width: 120, align: 'center',
                    formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' }
                },
                { label: '住院号', name: 'zyh', width: 80, align: 'center' },
                //{ label: '病人性质', name: 'brxz', width: 80, align: 'center' },
                { label: '总费用', name: 'zje', width: 100, align: 'center' },
                { label: '现金支付', name: 'xjzf', width: 100, align: 'center' },
                {
                    label: '结算状态', name: 'jszt', width: 80, align: 'center', formatter: function (val) {
                        return $.enum.getDescByValue("EnumJieSuanZT", val);
                    }
                },
                {
                    label: '结算性质', name: 'jsxz', width: 80, align: 'center', formatter: function (val) {
                        if (val == "2") {
                            return "中途结算";
                        }
                        else 
                            return "出院结算";
                    }
                },
                { label: '发票号', name: 'fph', width: 100, align: 'center' },
                //{ label: '账户支付', name: 'acct_pay', width: 80, align: 'center' },
                //{ label: '账户余额', name: 'balc', width: 80, align: 'center' }
            ],
            ondblClickRow: function (rowIndex, s) {
                getSettInfo();
            },
            //gridComplete: function () {
            //    var ids = $('#gridListsett').getDataIDs();//返回数据表的ID数组["66","39"..] 
            //    var rowData = $("#gridListsett").getRowData(ids[0]);
            //    getSettInfo(rowData.jsnm, rowData.setl_id);
            //},
            //caption: "结算信息"
        });
    }
    function getSettInfo(jsnm, settid) {
        var setttime = "";
        if (!jsnm) {
            jsnm = $("#gridListsett").jqGridRowValue().jsnm;
            settid = $("#gridListsett").jqGridRowValue().setl_id;
            setttime = $("#gridListsett").jqGridRowValue().setl_time;
        }

        if (!jsnm) {
            $.modalAlert("请选择一条结算记录", 'warning');
        }
        $.najax({
            url: "/PatientManage/PatientCenter/PatZySettInfobyJsnm",
            data: { jsnm: jsnm, settid: settid },
            dataType: "json",
            async: false,
            success: function (data) {
                if (data != null) {
                    for (var e in data) {
                        if (!!$("#lb_" + e) && data[e] != null) {
                            if (data[e] === 0) {
                                $("#lb_" + e).html("0.00");
                            }
                            else if (e == "setl_time" && !setttime) {
                                var text = $.getTime({ date: data[e] });
                                $("#lb_" + e).html(text);
                            }
                            else if (!!parseFloat(data[e])) {
                                $("#lb_" + e).html(parseFloat(data[e]).toFixed(2));
                            }
                            else {
                                $("#lb_" + e).html(data[e]);
                            }
                        }
                    }
                }
                if (!!settid) {
                    $("#lb_xjzf").html((parseFloat(data.psn_cash_pay) + parseFloat(data.medfee_sumamt) - parseFloat(data.medfee_sumamt)).toFixed(2));
                    $("#lb_fybxjzf").html((parseFloat(data.medfee_sumamt) - parseFloat(data.medfee_sumamt)).toFixed(2));
                }
                $("#lb_setl_time").html(setttime);
            }
        });
    }

</script>